package com.example.swimmingpool.controller.course_selection;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.swimmingpool.qo.course_selection.CourseSelectionQo;
import com.example.swimmingpool.response.CommonResponse;
import com.example.swimmingpool.service.course_selection.CourseSelectionService;
import com.example.swimmingpool.vo.course.CourseQueryVo;
import com.example.swimmingpool.vo.course_selection.CourseSelectionVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/course_selection")
public class CourseSelectionController {
    @Resource
    private CourseSelectionService courseSelectionService;

    @PostMapping("/select")
    public CommonResponse<Boolean> choose(@RequestBody CourseSelectionQo qo) {
        var res = courseSelectionService.chooseCourse(qo);
        return CommonResponse.success(res);

    }

    @PostMapping("/list")
    public CommonResponse<IPage<CourseQueryVo>> list(@RequestBody CourseSelectionQo qo) {
        var pages = courseSelectionService.list(qo);
        return CommonResponse.success(pages);
    }

    @PostMapping("/listAll")
    public CommonResponse<IPage<CourseSelectionVo>> listAll(@RequestBody CourseSelectionQo qo) {
        var pages = courseSelectionService.listAll(qo);
        return CommonResponse.success(pages);
    }

    @PostMapping("/delete")
    public CommonResponse<Boolean> delete(@RequestBody CourseSelectionQo qo) {
        var res = courseSelectionService.delete(qo);
        return CommonResponse.success(res);
    }

    @PostMapping("/listChosenIds")
    public CommonResponse<List<String>> listChosenIds() {
        return CommonResponse.success(courseSelectionService.getChoosenList());
    }
}
